package com.lonely.fx;

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.image.Image;
import javafx.scene.layout.*;
import javafx.scene.paint.Color;
import javafx.stage.Stage;
import javafx.stage.StageStyle;

/**
 * @date: 2022-07-01 11:34
 * @author: ztkj-hzb
 * @description:
 **/
public class 使用图片作为启动页 extends Application {

    public static void main(String[] args) {
        launch(args);
    }

    /**
     *
     */
    @Override
    public void start(Stage primaryStage) throws Exception {

        BorderPane borderPane = new BorderPane();

        BackgroundSize size = new BackgroundSize(BackgroundSize.AUTO,
                BackgroundSize.AUTO,
                false,
                false,
                true,
                false);

        Background background = new Background(new BackgroundImage(new Image("/icons/start.png"),
                BackgroundRepeat.NO_REPEAT,
                BackgroundRepeat.NO_REPEAT,
                BackgroundPosition.CENTER,
                size));

        borderPane.setBackground(background);

        Scene scene = new Scene(borderPane);

        //设置背景色透明
        scene.setFill(Color.TRANSPARENT);

        primaryStage.setScene(scene);

        primaryStage.setWidth(600);
        primaryStage.setHeight(500);

        //设置窗口样式，不然会有操作栏
        primaryStage.initStyle(StageStyle.TRANSPARENT);

        primaryStage.show();
    }
}
